<?php
/**
 * 用户模型
 * 现主要应用场景，在模型内获取当前登录用户信息
 */
class Model_User {
	private static $_currentLoginUser;

	/**
	 * 获取当前登录用户
	 * 例如要获取登陆用户id， Model_User::currentLoginUser()->user_id;用户未登陆，会返回null
	 * @return [type] [description]
	 */
	public static function currentLoginUser() {
		if (null === self::$_currentLoginUser) {
			self::$_currentLoginUser = new class {
				function __get($name) {
					return isset($this->info[$name]) ? $this->info[$name] : null;
				}
			};

			if (isset(Zend_Registry::get('_session')->currentLoginUser)) {
				self::$_currentLoginUser->info = Zend_Registry::get('_session')->currentLoginUser;
			}
		}

		return self::$_currentLoginUser;
	}
}